package cn.school.controller.student;


import cn.school.common.api.CommonPage;
import cn.school.common.api.CommonResult;
import cn.school.student.service.ConsultPlanInfoService;
import cn.school.student.vo.ConsultPlanInfoVO;
import cn.school.student.vo.ConsultPlanPersonVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "consult info => 咨询信息")
@RequestMapping("/consult/plan")
public class ConsultPlanInfoController {

    @Autowired
    private ConsultPlanInfoService consultPlanInfoService;

    @ApiOperation("getPlanInfoPageList => 分页查询计划信息")
    @PostMapping("/getPlanInfoPageList")
//    @PreAuthorize("@ss.hasPermi('consult:enroll:list')")
    public CommonResult<CommonPage<Map<String,Object>>> getPlanInfoPageList(@RequestBody ConsultPlanInfoVO vo){
        CommonPage<Map<String,Object>> pageList = consultPlanInfoService.getPlanInfoPageList(vo);
        return CommonResult.success(pageList);
    }

    @ApiOperation("addOrupdatePlanInfo => 新增or修改计划")
    @PostMapping("/addOrupdatePlanInfo")
//    @PreAuthorize("@ss.hasPermi('consult:enroll:list')")
    public CommonResult<Integer> addOrUpdatePlanInfo(@RequestBody ConsultPlanInfoVO vo){
        int num = consultPlanInfoService.addOrupdatePlanInfo(vo);
        if(num>0){
            return CommonResult.success();
        }
        return CommonResult.failed();
    }

    @ApiOperation("deletePlanInfo => 删除计划")
    @PostMapping("/deletePlanInfo")
//    @PreAuthorize("@ss.hasPermi('consult:enroll:list')")
    public CommonResult<Integer> deletePlanInfo(@RequestBody ConsultPlanInfoVO vo){
        int num = consultPlanInfoService.deletePlanInfo(vo);
        if(num>0){
            return CommonResult.success();
        }
        return CommonResult.failed();
    }

    @ApiOperation("getParentPlanList => 查询上级计划")
    @PostMapping("/getParentPlanList")
//    @PreAuthorize("@ss.hasPermi('consult:enroll:list')")
    public CommonResult<List<Map<String,Object>>> getParentPlanList(@RequestBody ConsultPlanInfoVO vo){
        List<Map<String,Object>> list = consultPlanInfoService.getParentPlanList(vo);
        return CommonResult.success(list);
    }

    @ApiOperation("getPersonListByPlanId => 查询参与计划的人员")
    @PostMapping("/getPersonListByPlanId")
//    @PreAuthorize("@ss.hasPermi('consult:enroll:list')")
    public CommonResult<List<ConsultPlanPersonVO>> getPersonListByPlanId(@RequestBody ConsultPlanPersonVO vo){
        List<ConsultPlanPersonVO> list = consultPlanInfoService.getPersonListByPlanId(vo.getPlanId()+"");
        return CommonResult.success(list);
    }



}
